********************************************************************************
** 	TITLE: f7_attrition.do
**
**	PROJECT: IGNITE
** 
**  PURPOSE: Appendix Table IX: Differential Attrition

********************************************************************************
set sortseed 13

	use "$output_data/estimate.dta", replace

***attrition table by months 3, 6, 9, 12. 
	qui forvalues j=3(3)12{
		cap drop attrit_`j'm_fp
		gen attrit_`j'm_fp = 1-attrit_`j'm
		reghdfe attrit_`j'm_fp D_remove_any $auxiliary_control, cluster(inmate) a($design_control)
		eststo att_`j'
		su attrit_`j'm_fp if e(sample)&D_remove_any==0
		local meancont: di %8.3f r(mean)
		estadd local meancont "`meancont'":  att_`j'
		estadd local basecont "Yes":  att_`j'
		estadd local demo_case "Yes": att_`j'
	}
	
	estout att_3 att_6 att_9 att_12   ///
				using "$tables/attrition.tex", style(tex)  ///
				label nobaselevels collabels(none) mlabels(none) /// 
				keep(D_remove_any) ///
				varlabel(D_remove_any "Court Delay") ///
				cells(b(star fmt(%8.3f)) se(par fmt(%8.3f))) /// 
				starlevels(* 0.10 ** 0.05 *** 0.01) ///  
				stats(foo meancont basecont demo_case N, ///
				fmt(0 %8.3f 0 0 0 0 0 0 0) /// 
				labels("\hspace{0.5cm}" "Control Mean"  ///
					"Design Controls" "Auxiliary Controls" "Observations"))	replace